home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 18 / AMIGAplus Sonderheft 18 (1999)(ICP)(DE)[!].iso / Forum / MichaelRoth / 3-3-99 / code / code3 < prev    next >
Text File  |  1998-08-15  |  6KB  |  219 lines

  1. ;// Autor
  2. ;                            %
  3. ;                          %%*%%
  4. ;                        %%%* *%%%
  5. ;                      %%%%* B *%%%%
  6. ;                    %%%%%*  T  *%%%%%
  7. ;                  %%%%%%*   B   *%%%%%%
  8. ;                %%%%%%%*    1    *%%%%%%%
  9. ;              %%%%%%%%*     3     *%%%%%%%%
  10. ;          *%%%%%%%%%%*      M      *%%%%%%%%%%*
  11. ;        %%%%%%%%%%%%*---------------*%%%%%%%%%%%%
  12. ;       %%              A M I G A                %%
  13. ;      %%      B i l l y   T h e   B y t e        %%
  14. ;       %%        © 1997  Michael Roth           %%
  15. ;        %%%%%%%%%%%%*---------------*%%%%%%%%%%%%
  16. ;          *%%%%%%%%%%*      D      *%%%%%%%%%%*
  17. ;              %%%%%%%%*     A     *%%%%%%%%
  18. ;                %%%%%%%*    C    *%%%%%%%
  19. ;                  %%%%%%*   6   *%%%%%%
  20. ;                    %%%%%*  9  *%%%%%
  21. ;                      %%%%* 8 *%%%%
  22. ;                        %%%* *%%%
  23. ;                          %%*%%
  24. ;                            %
  25. ;\\
  26.  
  27. ;// Include
  28.           Include  assem:macro/Dir
  29.           Include  assem:macro/Exec.m
  30.           Include  assem:macro/Dos.m
  31.           Include  Dos/DosExtens.i
  32.           include  macro/filelength
  33. ;\\
  34.  
  35. ;// Libraries öffnen
  36.           OpenDos  37
  37. ;\\
  38.  
  39. ;//ReadArgs
  40.           move.l   #inputstr,d1                  ; Eingabe String
  41.           move.l   #arry,d2                      ; Arry
  42.           move.l   #0,d3                         ; Keine Externe Structur
  43.           Dos      ReadArgs                      ; Argumente Lesen
  44.           move.l   d0,rdargs                     ; speichern
  45.           bne.s    .1                            ; prüfen ob alles o.k.
  46.           error    cleanup,20                    ; o.k. >.1 Ansonsten Fehlermeldung beenden
  47. .1                                               ;
  48.           lea   arry,a0                          ; Arry nach a0
  49. ;\\
  50.  
  51. ;//File Öffnen und gröe bestimmen
  52.           move.l   (a0),d1
  53.           move.l   #MODE_OLDFILE,d2              ; 1005
  54.           Dos      Open                          ; File Öffnen
  55.           bne.s    .2
  56.           error    cleanup,20
  57. .2
  58.           move.l   d0,fh
  59.           filelength fh,filelänge                ; Filelänge bestimmen
  60. ;\\
  61.  
  62. ;// Speicher Reservieren
  63.          move.l    filelänge,d0
  64.          move.l    #MEMF_CLEAR,d1
  65.          Exec      AllocMem
  66.          move.l    d0,memblock
  67.          bne.s     .memallockok
  68.          error     cleanup,20
  69. .memallockok
  70. ;\\
  71.  
  72. ;// File einlesen
  73.          move.l   fh,d1
  74.          move.l   memblock,d2
  75.          move.l   filelänge,d3
  76.          Dos      Read
  77.          cmp.l    filelänge,d0
  78.          beq.s    .readok
  79.          error    cleanup,20
  80. .readok
  81. ;\\
  82.  
  83. key
  84. ;//File Öffnen und gröe bestimmen
  85.           lea      arry,a0                          ; Arry nach a0
  86.           move.l   8(a0),d1
  87.           move.l   #MODE_OLDFILE,d2              ; 1005
  88.           Dos      Open                          ; File Öffnen
  89.           bne.s    .2
  90.           error    cleanup,20
  91. .2
  92.           move.l   d0,fh2
  93.           filelength fh2,filelänge2                ; Filelänge bestimmen
  94. ;\\
  95.  
  96. ;// Speicher Reservieren
  97.          move.l    filelänge2,d0
  98.          move.l    #MEMF_CLEAR,d1
  99.          Exec      AllocMem
  100.          move.l    d0,memblock2
  101.          bne.s     .memallockok
  102.          error     cleanup,20
  103. .memallockok
  104. ;\\
  105.  
  106. ;// File einlesen
  107.          move.l   fh2,d1
  108.          move.l   memblock2,d2
  109.          move.l   filelänge2,d3
  110.          Dos      Read
  111.          cmp.l    filelänge2,d0
  112.          beq.s    .readok
  113.          error    cleanup,20
  114. .readok
  115. ;\\
  116.  
  117. code
  118. ;// Codieren
  119. ******************************************************************
  120.          move.l   memblock,a0                          ; Startadresse des Klartextes
  121.          move.l   memblock2,a1                         ; "" des Keys
  122.          move.l   filelänge,d0                   ; Länge des Buffers
  123.          move.l   filelänge2,d1                  ; Länge des Keys
  124.          lea      (a0,d0),a2                     ; Endadresse des Buffers berechnen
  125.          lea      (a1,d1),a3                     ; """" des Keys
  126. .loop1
  127.          move.b   (a1)+,d4
  128.          eor.b    d4,(a0)+                        ; XNOR bilden
  129.          cmp.l    a1,a3                           ; Prüfen ob Key am Ende
  130.          bhi.s    .ggoon                          ; wenn nein weiter
  131.          move.l   memblock2,a1                    ; ansonsten neu laden
  132. .ggoon                                            ;
  133.          cmp.l    a0,a2                           ; Prüfen ob Buffer am Ende
  134.          bhi.s    .loop1                          ; Nein -> nächste schleife
  135.  
  136.  
  137. ********************************************************************
  138. ;\\
  139.  
  140. ;// Zielfile Öffnen
  141.          lea       arry,a0                          ; Arry nach a0
  142.          move.l    4(a0),d1
  143.          move.l    #MODE_NEWFILE,d2
  144.          Dos       Open
  145.          move.l    d0,d7
  146.          bne       .ok
  147.          error     cleanup,20
  148. .ok
  149.  
  150.          move.l    d7,d1
  151.          move.l    memblock,d2
  152.          move.l    filelänge,d3
  153.          Dos       Write
  154.  
  155.          move.l    d7,d1
  156.          Dos       Close
  157. ;\\
  158.  
  159. ;// CleanUp
  160. cleanup
  161.           move.l   rdargs,d1
  162.           beq.s    .end                          ; Argumente da ?
  163.           Dos      FreeArgs                      ; Wenn Nein beenden
  164.  
  165.           move.l   fh,d1
  166.           beq.s    .1                            ; File geöffnet
  167.           Dos      Close                         ; Wenn nein weiter
  168. .1
  169.           move.l    memblock,d0
  170.           beq.s     .2
  171.           move.l    d0,a1
  172.           move.l    filelänge,d0
  173.           Exec      FreeMem
  174. .2
  175.           move.l   fh2,d1
  176.           beq.s    .3                            ; File geöffnet
  177.           Dos      Close                         ; Wenn nein weiter
  178. .3
  179.           move.l    memblock2,d0
  180.           beq.s     .4
  181.           move.l    d0,a1
  182.           move.l    filelänge2,d0
  183.           Exec      FreeMem
  184. .4
  185.  
  186.  
  187.  
  188. .end
  189.           closedos
  190.           moveq    #0,d0
  191.           rts
  192. ;\\
  193.  
  194. ;// Data
  195.  DATA
  196.  
  197. ver   dc.b "$VER: V0 - Written by DAC698 - Michael Roth",0
  198. inputstr
  199.          dc.b      "Source/A,Dest/A,Key/A",0 ;KeyFile/S",0
  200. cr
  201.          dc.b      10,0
  202.  
  203.  BSS
  204.  cnop 0,4
  205. arry     ds.l      3
  206. rdargs   ds.l      1
  207. fh       ds.l      1
  208. fh2      ds.l      1
  209. filelänge
  210.          ds.l      1
  211. memblock ds.l      1
  212. filelänge2
  213.          ds.l      1
  214. memblock2
  215.          ds.l      1
  216. insert   dc.b      4,0
  217. ;\\
  218.  
  219.